import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:yp/config/index.dart';

class ShopName extends StatelessWidget {
  /// 标题
  final String title;

  /// 是否展示前面的商铺icon
  final bool showIcon;

  /// 店铺销售状态
  final String shopState;

  /// 后边的订单状态
  final String orderState;
  const ShopName(this.title,
      {Key key, this.showIcon = true, this.shopState, this.orderState})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: const EdgeInsets.fromLTRB(12, 12, 12, 10),
      child: Row(
        children: [
          Visibility(
            visible: showIcon,
            child: Padding(
              padding: const EdgeInsets.only(right: 6),
              child: Image(
                image: AssetImage("assets/images/orderStore.png"),
                width: 36.w,
              ),
            ),
          ),
          Container(
            constraints:
                BoxConstraints(maxWidth: MediaQuery.of(context).size.width / 2),
            child: Text(
              title ?? '',
              maxLines: 1,
              overflow: TextOverflow.ellipsis,
              style: TextStyle(
                  color: EsColors.TitleSecondary,
                  fontSize: showIcon ? EsSizes.MD : EsSizes.SM,
                  fontWeight:
                      showIcon ? EsFontWeights.Medium : EsFontWeights.Normal),
            ),
          ),
          Visibility(
            visible: shopState?.isNotEmpty ?? false,
            child: Container(
              padding: const EdgeInsets.symmetric(vertical: 2, horizontal: 3),
              margin: const EdgeInsets.only(left: 6),
              decoration: BoxDecoration(
                  gradient: EsColorLiner.PortraitOrangeToYellowHorizontal,
                  borderRadius: BorderRadius.circular(3.0)),
              child: Text(shopState ?? '',
                  style: TextStyle(
                      color: EsColors.White,
                      fontSize: EsSizes.XXS,
                      fontWeight: EsFontWeights.Normal)),
            ),
          ),
          Expanded(child: SizedBox()),
          Visibility(
              visible: orderState?.isNotEmpty ?? false,
              child: Text(orderState ?? '',
                  style: TextStyle(
                      color: EsColors.Primary,
                      fontSize: EsSizes.SM,
                      fontWeight: EsFontWeights.Normal)))
        ],
      ),
    );
  }
}
